clear

 set more off
 
 
 
	
	* Import raw data 
		 import excel "$Replicationdirectory/_Data/Volume Data/All_Tranches.xlsx", sheet("Data") firstrow

		 
		 
		 encode Tranche, gen(tranche_enc)
		 
		  encode Market, gen(market_enc)
		  
		  
		 
		   
   
  ***** Calculate "others" share
		  
		  gen othercountries=1 if  Market=="Rome"   | Market=="Stockholm" 
		  
			drop if Market=="Berlin" | Market=="Redeemed"


		  
		  egen sum_othermarkets=sum(Value) if othercountries==1, by(Year Tranche)
		  
		  egen sum_othermarkets_all=mean(sum_othermarkets), by (Year Tranche)
		  
		  replace Value=sum_othermarkets_all if Market=="Others" 
		  
		  drop   if Market=="Rome"   | Market=="Stockholm" 
  
   
		  egen sum_all_ty=sum(Value), by (Year Tranche)
		  
		  replace Value=100* Value/sum_all_ty
		   
		 
 ****** Generate and combine graphs 
  
			  local countryofissue `"   "British" "French" "Belgian" "Dutch" "Swiss" "'
			  
			  foreach x of local countryofissue  {
			   
				preserve 
				
							   keep if Tranche=="`x'"
							   
							 
							   
							   sort Market

							  
							  gen London=Value if Market=="London"
							  
							  label var London "London"
							  
							  gen Paris=Value if Market=="Paris"
							  
								label var Paris "Paris"

								 
							  gen Brussels=Value if Market=="Brussels"
							  
							  label var Brussels "Brussels"
							  
							  
							  gen Amsterdam=Value if Market=="Amsterdam"
							  
							  label var Amsterdam "Amsterdam"
							  
							  
								gen Zurich=Value if Market=="Zurich"
							  
							  label var Zurich "Zurich"
							  
							  
								
							  
								gen Others=Value if Market=="Others"
							  
							  label var Others "Rome & Stockholm"
							  
								 
							  
							  

								graph bar    London Paris   Amsterdam Zurich Brussels   Others ,     bar(1, color(blue)) bar(2, color(red)) bar(3, color(dkorange)) bar(4, color(green)) 	 bar(5, color(purple))   bar(6, color(lavender))	over(Year)   stack	 graphregion(color(white)) legend(rows(2) order(1 "London" 2 "Paris"   3 "Amsterdam" 4 "Zurich" 5 "Brussels"    6 "Rome/Stockholm"  )  size(small) region(lcolor(none) ) subtitle("{stMono:Traded in...}")) title("{stMono:`x'}",  color(black)) 
								 
								graph save "$Replicationdirectory/_Work/TEMP/Tranches_Market_`x'.gph",    replace

				
				restore 
			}
			 
			 
			  
			 
						 
			 grc1leg      "$Replicationdirectory/_Work/TEMP/Tranches_Market_British.gph" "$Replicationdirectory/_Work/TEMP/Tranches_Market_French.gph" "$Replicationdirectory/_Work/TEMP/Tranches_Market_Dutch.gph" "$Replicationdirectory/_Work/TEMP/Tranches_Market_Belgian.gph" "$Replicationdirectory/_Work/TEMP/Tranches_Market_Swiss.gph",  			 l1("{stMono: % of Tranche} ")			 	legendfrom("$Replicationdirectory/_Work/TEMP/Tranches_Market_British.gph")   graphregion(color(white) ) 

			graph export "$Replicationdirectory/_Work/Output/Figures/Figure3_ShareBondsMarkets.pdf", replace 

			
			

			
			
 
  
* calculate MCAPS for footnote  
		   
		  *****   calculate Number of 100 pound bonds
		  
		  
		  gen N_Bonds=Value/100

		  
		  
		  
		  
		  sort Market Year
		  
		  
		  collapse (sum) N_Bonds, by(Market Year)
		  
		  
		  keep if Year==1934 
		   
		  keep if Market=="London" | Market=="Paris" | Market=="Amsterdam" | Market=="Zurich" 
		  
			 
			
			
			
				  
 
		
			
			
			
			 
